<?php $form = $this->beginWidget('CActiveForm'); ?>
<div class="well horizontal">
    <span>Chọn tháng</span> <?php echo CHtml::textField('date', null, array()); ?>
    <?php echo CHtml::submitButton('Xem', array('class' => 'btn btn-primary', 'name' => 'view')); ?>
</div>
<?php $this->endWidget(); ?>
<table class="table table-striped table-bordered table-condensed">
    <thead>
        <tr>
            <th>#</th>
            <th>Tên nhân viên</th>
            <?php for ($i = 1, $n = (int) date('t', strtotime($date)); $i <= $n; $i++): ?>
                <th class="cell-center">
                    <?php echo Utility::getDayInWeek(($i), $date) ?><br/>
                    <?php echo $i ?>
                </th>
            <?php endfor; ?>
    </thead>
    <tbody>
        <?php foreach ($users as $user): ?>
            <tr>
                <td><?php echo $user->id ?></td>
                <td>
                    <?php
                    echo CHtml::link($user->getName(), array(
                        'attendance/detail',
                        'user_id' => $user->id,
                        'date' => strtotime($date)
                    ));
                    ?>
                </td>
                <?php for ($i = 1, $n = (int) date('t', strtotime($date)); $i <= $n; $i++): ?>
                    <?php $row = $rows[$user->id][$i]; ?>
                    <td class="<?php echo ($row->isWeekend()) ? "cell-red" : "normal"; ?>"> 
                        <?php echo $row->getAttendanceDetails(); ?>
                    </td>
                <?php endfor; ?>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>
<div class="">
    <fieldset>
        <legend>Chú giải</legend>
        <ul>
            <li>S: Sáng</li>
            <li>T: Trưa</li>
            <li>C: Chiều</li>
            <li>Đ: Đi làm</li>
            <li>N: Nghỉ phép</li>
            <li>KL: Nghỉ không lương</li>
        </ul>
    </fieldset>
</div>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script>
    $(function() {
        $("#date").datepicker({
            changeMonth: true,
            changeYear: true,
            showButtonPanel: true
        });
        $("#date").datepicker('setDate', '<?php echo $date; ?>');
    });
</script>